using System;
using System.Collections.Generic;
using System.Text;
using Barrage.GUI;
using Barrage.GUI.Elements;
using Spacedash.Logic;
using Barrage.Global;

namespace Spacedash.Game.Subgames
{
    static class ModifyProfileElements
    {
        public const string SelectProfile = "PROFILE_SELECT";
        public const string ExitButton = "EXIT_BUTTON";
        public const string EditProfileButton = "EDIT_BUTTON";
        public const string DeleteProfileButton = "DELETE_BUTTON";
    }
    class ModifyProfileSection : GUISection
    {
        public override int Id
        {
            get { return (int)GameState.ModifyProfile; }
        }
        
        public ModifyProfileSection(SpacedashGame parent)
            : base("ModifyProfile", parent)
        {
            RegisterButtonEvent(ModifyProfileElements.ExitButton, new GUIButtonHandler(ExitButtonClick));
            RegisterButtonEvent(ModifyProfileElements.DeleteProfileButton, new GUIButtonHandler(DeleteButtonClick));
            RegisterButtonEvent(ModifyProfileElements.EditProfileButton, new GUIButtonHandler(EditButtonClick));

            int i=0;
            foreach (string name in Profile.GetAvailableProfiles())
            {
                ((GUISelector)Layout.Elements[ModifyProfileElements.SelectProfile]).addOption(i++, name);
            }
        }

        void DeleteButtonClick(string buttonId)
        {
            // Do nothing by now
        }

        void EditButtonClick(string buttonId)
        {
            string selectedProfile = ((GUISelector)Layout.Elements[ModifyProfileElements.SelectProfile]).CurrentOptionValue;
            parent.NextGameSection = new EditProfileSection(Profile.Load(selectedProfile),(SpacedashGame)parent);
        }

        void ExitButtonClick(string buttonId)
        {
            parent.NextGameSection = ((SpacedashGame)parent).GetSection((int)GameState.Profiles);
        }
    }
}
